from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def minArrivalsToDiscard(self, arrivals: List[int], w: int, m: int) -> int:
        ans = []
        windom = {}

        for right ,item in enumerate(arrivals):
            i = windom.get(item,0)
            if i < m:
                windom[item]= i+1
            else:
                ans.append(right)
            left = right - w +1
            if left >=0:
                l = arrivals[left]
                if left not in ans:
                    windom[l] -=1
        return len(ans)
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    print(solution.minArrivalsToDiscard([10,4,3,6,4,5,6,1,4],7,1))
    # your test code here